import itk
import vtk

# VTK will read the PNG image for us
#reader = vtk.vtkPNGReader()
reader = itk.ImageFileReader.IUC2.New()

reader.SetFileName('C:/Lib/JointTrack/branches/bryan/itktestimage.png')
reader.Update()

# convert from vtk to itk, and from itk to vtk

itk2vtk = itk.ImageToVTKImageFilter.IUC2.New()
itk2vtk.SetInput(reader.GetOutput())

vtk2itk = itk.VTKImageToImageFilter.IUC2.New()
vtk2itk.SetInput(itk2vtk.GetOutput())

itk.echo(vtk2itk)

##itk2vtk = itk.ImageToVTKImageFilter.IUC2.New()
##itk2vtk.SetInput(vtk2itk.GetOutput())

# finally write the image to disk using VTK (to confirm that it works)
#writer = vtk.vtkPNGWriter()
writer = itk.ImageFileWriter.IUC2.New()

writer.SetFileName('C:/Lib/JointTrack/branches/bryan/itkvtkoutput.png')
writer.SetInput(vtk2itk.GetOutput())

# write the file to disk...
writer.Update()
writer.Write()
